﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
using System.Web.SessionState;
using DTcms.Web.UI;
using DTcms.Common;

namespace DTcms.Web.m
{
    /// <summary>
    /// set_company_quanzi 的摘要说明
    /// </summary>
    public class set_company_quanzi : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string _user_name = DTRequest.GetString("txtUserName");
            string _user_pwd = DTRequest.GetString("txtPassword");

            if (string.IsNullOrEmpty(_user_name) || string.IsNullOrEmpty(_user_pwd))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"错误提示：用户名或密码错误！\"}");
                return;
            }

            Model.users userModel = new BLL.users().GetModel(_user_name, _user_pwd, 0, 1, true);
            if (userModel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"错误提示：用户名或密码错误！\"}");
                return;
            }
            //判断是否开通过店铺
            if (userModel.company_id == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"抱歉，您尚未开通店铺！\"}");
                return;
            }

            int quanzi_id = DTRequest.GetFormInt("quanzi_id", 0);
            if (quanzi_id==0)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"抱歉，请选择您要切换的圈子名称！\"}");
                return;
            }

            BLL.company bll = new BLL.company();
            bll.UpdateField(userModel.company_id, "quanzi_id=" + quanzi_id);
            context.Response.Write("{\"status\":1, \"msg\":\"圈子修改成功！\"}");
            return;
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}